package com.company.emenu.action;

import java.io.IOException;
import java.util.List;

import com.company.emenu.base.BaseAction;
import com.company.emenu.base.ExtTableBean;
import com.company.emenu.base.JqGridUtil;
import com.company.emenu.base.Page;
import com.company.emenu.base.QueryParameter;
import com.company.emenu.entity.SysYhxx;
import com.company.emenu.service.ISysYhxxService;

/**
 * @ClassName: SysYhxxAction
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author Rain
 * @date 2012-7-15 下午12:46:34
 */
public class SysYhxxAction extends BaseAction {

	private ISysYhxxService sysyhxxService;
	private SysYhxx sysyhxx = new SysYhxx();
	private QueryParameter paramert = new QueryParameter();

	private String loginStatus;

	private Integer id;
	private String ywid;
	private String dlm;
	private String mm;
	private String xm;
	private String cjr;
	private String cjsj;
	private String sfyx;
	
	
	


	public QueryParameter getParamert() {
		return paramert;
	}


	public String getLoginStatus() {
		return loginStatus;
	}

	public SysYhxx getSysyhxx() {
		return sysyhxx;
	}

	public void setId(Integer id) {
		sysyhxx.setId(id);
	}

	public void setYwid(String ywid) {
		sysyhxx.setYwid(ywid);
	}

	public void setDlm(String dlm) {
		sysyhxx.setDlm(dlm);
	}

	public void setMm(String mm) {
		sysyhxx.setMm(mm);
	}

	public void setXm(String xm) {
		sysyhxx.setXm(xm);
	}

	public void setCjr(String cjr) {
		sysyhxx.setCjr(cjr);
	}

	public void setCjsj(String cjsj) {
		sysyhxx.setCjsj(cjsj);
	}

	public void setSfyx(String sfyx) {
		sysyhxx.setSfyx(sfyx);
	}

	public void setSysyhxxService(ISysYhxxService sysyhxxService) {
		this.sysyhxxService = sysyhxxService;
	}

	public String login() {
		SysYhxx yhxx = sysyhxxService.login(sysyhxx);
		String result = "failure";
		if (yhxx == null) {
			loginStatus = "failure";
			result = "failure";
		} else {
			this.getSession().put("loginUser", yhxx.getDlm());
			loginStatus = "success";
			result = "success";
		}
		return result;
	}
	
	public String list(){
		return "success";
	}
	
	
	public String listBean(){
//		String path = getRequest().getSession().getServletContext().getRealPath("/");
	    String 	coljson = this.list(this.getParamert(),  "D:\\workspaces\\eMenu-Business-Management\\src\\main\\resource\\tableXml\\list\\xtyh.xml");
		System.out.println(coljson);
		try {
			getResponse().setCharacterEncoding("UTF-8"); 
			getResponse().getWriter().write(coljson);
			getResponse().getWriter().close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	public String getGridJson(){
		String page = getRequest().getParameter("page"); // 取得当前页数
		String rows = getRequest().getParameter("rows"); // 取得每页显示行数
		String sortname = getRequest().getParameter("sidx"); // 取排序的字段
		String sortorder = getRequest().getParameter("sord"); // 取排序的方式
		//自定义查询条件参数
		String sortn = getRequest().getParameter("filters");
		String hqlWhere = "";
		hqlWhere = JqGridUtil.hqlWhereByFilters("x", sortn);
		QueryParameter parameter = getParamert();
		Page pages = parameter.getPages();
		pages.setCurrentPage(Integer.parseInt(page));
		pages.setPageSize(Integer.parseInt(rows));
		userInfoList = sysyhxxService.getSysyhxxAll();
		return "json";
	}
	
	private List<SysYhxx> userInfoList;

	public List<SysYhxx> getUserInfoList() {
		return userInfoList;
	}
	
	
	
}
